#!/bin/sh
# installed mpich2 from mpich2-1.0.3-1-win32-ia32.msi from
# http://www-unix.mcs.anl.gov/mpi/mpich2/index.htm#download
# Note: "This setup requires the .NET Framwork version 1.1.4322..." 
# and they really mean 1.1, not 2.0 and not 1.0.
# Installed in c:/mpich2 to avoid spaces in paths.
# First get to the point where you can run cpi.exe example. May need to
# give yourself a login password.

export CFLAGS="-mwindows -I/cygdrive/c/mpich2/include"
export CXXFLAGS="-mwindows -I/cygdrive/c/mpich2/include"
export LIBS="-L/cygdrive/c/mpich2/lib -lmpi"
export LDFLAGS="-e _mainCRTStartup"

#build InterViews with above environment also

./configure --prefix=`pwd` --with-paranrn --with-iv=$HOME/neuron/ivmpi

# make
# make mswin
# in the src/parallel directory one can launch any of the tests with, e.g.
# c:/mpich2/bin/mpiexec -np 1 c:\\marshalnrn\\nrn\\bin\\nrniv.exe -mpi test0.hoc


if false
#notes about building with mpich2 under cygwin.
#I have used it with multicore desktops.
#In my $HOME
curl -O http://www.mcs.anl.gov/research/projects/mpich2/downloads/tarballs/1.4/mpich2-1.4.tar.gz
tar xzf mpich*gz
cd mpich2-1.4
#For mpich2-1.4 I configured with:
./configure --prefix=$HOME/mpich2  --with-pm=gforker:mpd \
  'CFLAGS=-DDLL_EXPORT -DPIC' 'CXXFLAGS=-DDLL_EXPORT -DPIC' \
  'LDFLAGS=-Wl,--enable-auto-import'
make >& build.stdout
# note that the build.stdout is needed by src/mswin/nrncygso.sh
make install
# mpichs2-1.4 was added to my PATH
# note that the install step is needed to find the mpd and related executables
# in the mpich2/bin folder,
# since only the gforker version of mpiexec.exe appears in mpich2-1.4/bin
# folder after a make.
# The reason for making gforker the default is that mpd sometimes fails to
# operate correctly on user machines. gforker is limited to
# launching on a single node(multcore) but that is the most typical situation
# and makes it possible to use the bulletin board system on mulitcore desktops.
# If the parallel machine is a cluster environment then it will be
# necessary to use the mpd style for launching. i.e mpdboot on the master
# or mpd& on every node and then launch with mpiexe.mpd
# A test on a single node useing gforker is
# mpiexec -n 2 echo 'hello'
# A test on a single node using mpd is
# mpd&
# mpiexec.mpd -n 2 echo 'hello'
# mpdallexit
fi
